#include "label.h"
#include <QDebug>
#include <QMouseEvent>


Label::Label(QWidget*prent): QLabel(prent)
{

}

void Label::enterEvent(QEvent * event)
{

//    qDebug()<<"enterEvent";
}

void Label::leaveEvent(QEvent * event)
{
//    qDebug()<<"leaveEvent";
}

void Label::mousePressEvent(QMouseEvent *event)
{
    if(event->button()==Qt::LeftButton)
    {
        qDebug()<<"按下了左键";
    }
    else if(event->button() == Qt::RightButton)
    {
        qDebug()<<"按下了右键";
    }
//    //当鼠标点击label区域时打印坐标
//    qDebug()<<event->x()<<" "<<event->y()<<" ";
//    //打印相对于屏幕的坐标
    //    qDebug()<<event->globalX()<<" "<<event->globalY()<<" ";
}

void Label::mouseReleaseEvent(QMouseEvent *event)
{
    if(event->button()==Qt::LeftButton)
    {
        qDebug()<<"左键被松开了";
    }
    else if(event->button() == Qt::RightButton)
    {
        qDebug()<<"右键被松开了";
    }
}

void Label::mouseDoubleClickEvent(QMouseEvent *event)
{
    if(event->button()==Qt::LeftButton)
    {
        qDebug()<<"双击了左键";
    }
    else if(event->button() == Qt::RightButton)
    {
        qDebug()<<"双击了右键";
    }
}
